package fi.pakkanen.yarpg.item;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

import fi.pakkanen.yarpg.item.trait.Equippable;

/**
 * An equipable item.
 * 
 * @author Oliver Michels <oliver.michels@gmx.net>
 * 
 */
public class EquippableItem extends AbstractItem implements Equippable {

	/** The valid states for this item */
	private static Set<ItemState> validStates;

	static {
		ItemState[] valids = { ItemState.INACTIVE, ItemState.EQUIPPED };
		validStates = new HashSet<ItemState>(Arrays.asList(valids));
	}

	/**
	 * Create a new item that can be equipped.
	 */
	public EquippableItem() {
		super(ItemState.INACTIVE);
	}

	@Override
	public boolean isEquippable() {
		return true;
	}

	@Override
	public void equip() {
		if (!isEquipped()) {
			if (!changeState()) {
				// TODO - Error msg
			}
		} else {
			// TODO - Error msg
		}
	}

	@Override
	public void unequip() {
		if (isEquipped()) {
			if (!changeState()) {
				// TODO - Error msg
			}
		} else {
			// TODO - Error msg
		}
	}

	@Override
	public boolean isEquipped() {
		return isState(ItemState.EQUIPPED);
	}

	@Override
	public boolean invoke() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	public boolean revert() {
		// TODO Auto-generated method stub
		return true;
	}

	@Override
	protected Set<ItemState> getValidStates() {
		return validStates;
	}

}
